﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Linq;


public partial class User
{
    public void SetId(long id)
    {
        this.m_Id = id;
    }
    
    public User(long id, string nickName, string token,int maxLv ,int coin, int diamond,bool isRobot,int loginDay,
        List<int>obtainedLoginBonus,List<long> friends,UserInfo userInfo)
    {
        this.m_Id = id;
        this.m_Nick = nickName;
        this.m_Token = token;
        this.m_MaxLv = maxLv;
        this.m_Coin = coin;
        this.m_Diamond = diamond;
        this.m_IsRobot = isRobot;
        this.m_LoginedDay = loginDay;
        this.m_ObtainLoginBonus = obtainedLoginBonus;
        this.m_UserInfo = userInfo;
        this.m_Friends = friends;
    }

    public int AddDiamond(int addNum)
    {
        int diamond = this.m_Diamond  + addNum;
        UpdateDiamond(diamond);

        return diamond;
    }

    public int MinusDiamond(int minusNum)
    {
        int diamond = this.m_Diamond - minusNum;
        diamond = diamond < 0 ? 0 : diamond;
        UpdateDiamond(diamond);

        return diamond;
    }
    
    public void UpdateStageLevel(int stage)
    {
        this.m_Level = stage;
    }

    public int AddLoginDay()
    {
        m_LoginedDay++;
        return m_LoginedDay;
    }
    public void ObtainLoginBonus(int day)
    {
        this.m_ObtainLoginBonus.Add(day);
    }

    public void UpdateBaseInfo(UserBaseInfoData userBaseInfoData,string iconUrl)
    {
        userInfo.gender = userBaseInfoData.gender;
        userInfo.birthYear = userBaseInfoData.birthYear;
        userInfo.eduation = userBaseInfoData.edu;
        userInfo.locationProvince = userBaseInfoData.locationProvince;
        userInfo.locationCity = userBaseInfoData.locationCity;
        userInfo.icon = iconUrl;
    }
    public void UpdateDetailInfo(UserDetailInfoData infoData)
    {
        userInfo.height = infoData.height;
        userInfo.weight = infoData.weight;
        userInfo.maritalStatus = infoData.maritalStatus;
        userInfo.hometownProvince = infoData.hometownProvince;
        userInfo.hometownCity = infoData.hometownCity;
        userInfo.job = infoData.job;
    }
    public void UpdateIntroduction(int type,string content)
    {
        if (type == IntroductioType.aboutMe)
            userInfo.aboutMe = content;
        else if (type == IntroductioType.familyBackground)
            userInfo.familyBackground = content;
        else if (type == IntroductioType.interest)
            userInfo.interest = content;
        else if (type == IntroductioType.loveView)
            userInfo.loveView = content;
        else if (type == IntroductioType.idealCompanion)
            userInfo.idealCompanion = content;
    }

    public void UpdatePhotoInfo(int texId,string tex)
    {
        if (texId == TexId.tex1) this.userInfo.tex1 = tex;
        if (texId == TexId.tex2) this.userInfo.tex2 = tex;
        if (texId == TexId.tex3) this.userInfo.tex3 = tex;
        if (texId == TexId.tex4) this.userInfo.tex4 = tex;
        if (texId == TexId.tex5) this.userInfo.tex5 = tex;
        if (texId == TexId.tex6) this.userInfo.tex6 = tex;
    }

}

